home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / THINKC / 5 / CHASSIS_ / TEXTWIND.C < prev    next >
Text File  |  1992-05-14  |  4KB  |  140 lines

  1. /************************************************************************************/
  2. /*    TextWindowProc                                                                    */
  3. /************************************************************************************/
  4.  
  5. #include "MyHeaders.h"
  6.  
  7. int TextWindowProc()
  8. {
  9.     int        TextWindRetCode = 0;
  10.     int        workPart;
  11.     int        h,v;
  12.     Rect    sizeRect;
  13.     ControlHandle    workControlHandle;
  14.     
  15.     SetPort (windTbl[windSub].windPtr);            /* set as the grafPort                */
  16.  
  17.     TEIdle (windTbl[windSub].windTEH[0]);
  18.  
  19.     workPoint = myEvent.where;
  20.     GlobalToLocal(&workPoint);
  21.  
  22.     switch (myEvent.what)                        /* how did I get here?                */
  23.         {
  24.         case (mouseDown):                        /* MouseDown?                        */
  25.             switch (myMouseWhere)                /*   What part of window?            */
  26.                 {
  27.                 case (inContent):                /*     content region:                */
  28.                     workPart = FindControl (workPoint,        /* check for control    */
  29.                             windTbl[windSub].windPtr,
  30.                             &workControlHandle);
  31.                     if (workPart)                    /* if so, track it                */
  32.                         {
  33.                          if (workPart != inThumb)    /* if not in thumb: use my proc    */
  34.                                                      /* to scroll and reset thumb    */
  35.                                                      /* on the basis of the scroll    */
  36.                             TrackControl (workControlHandle, workPoint, (ProcPtr) -1);
  37.                             
  38.                         else                        /* in thumb: use native routine    */
  39.                             {                        /* then invoke my proc to        */
  40.                                                     /* scroll on the basis of thumb    */
  41.                             k = GetCtlValue (workControlHandle);
  42.                             TrackControl (workControlHandle, workPoint, NIL);
  43.                             k -= GetCtlValue (workControlHandle);
  44.                             myActionProc(workControlHandle, (short) workPart);
  45.                             }
  46.                         }
  47.                     else
  48.                     if ( PtInRect(workPoint,
  49.                             &(**windTbl[windSub].windTEH[0]).viewRect) )
  50.                         {
  51.                         if ( BitAnd(myEvent.modifiers, shiftKey) )
  52.                             TEClick(workPoint, TRUE, windTbl[windSub].windTEH[0]);
  53.                         else
  54.                             TEClick(workPoint, FALSE, windTbl[windSub].windTEH[0]);
  55.                         WorkRetCode = MenuUpdate(ProcText);        /* reset menus        */
  56.                         }
  57.                 break;
  58.                 
  59.                 case (inDrag):                    /*     drag region:                    */
  60.                     DragWindow (windTbl[windSub].windPtr,
  61.                                 myEvent.where, &myDragRect);
  62.                 break;
  63.                 
  64.                 case (inZoomIn):
  65.                 case (inZoomOut):
  66.                     workBoolean = TrackBox (windTbl[windSub].windPtr,
  67.                             myEvent.where, myMouseWhere);
  68.                     if (workBoolean)
  69.                         {
  70.                         ZoomWindow (windTbl[windSub].windPtr,
  71.                             myMouseWhere, TRUE);
  72.                         WorkRetCode = TextResizeProc();
  73.                         }
  74.                 break;
  75.                         
  76.                 case (inGrow):                    /*     grow region:                    */
  77.                     SetRect (&sizeRect, 160,84,1200,900);    /* limits for grow size    */
  78.                     worklong = GrowWindow (windTbl[windSub].windPtr,
  79.                                 myEvent.where, &sizeRect);
  80.                     
  81.                     if (worklong)                                /* if size changedâ•”*/
  82.                         {
  83.                         v = HiWord(worklong);
  84.                         h = LoWord(worklong);
  85.                         SizeWindow (windTbl[windSub].windPtr, h, v, TRUE);
  86.                         WorkRetCode = TextResizeProc();
  87.                         }
  88.                 break;
  89.                 
  90.                 case (inGoAway):                /*     goaway region:                */
  91.                     if (TrackGoAway (windTbl[windSub].windPtr, myEvent.where))
  92.                         WorkRetCode = TextCloseProc();
  93.                 break;
  94.                 }
  95.              
  96.         break;
  97.         
  98.         case(autoKey):
  99.         case(keyDown):
  100.             workChar = (char) BitAnd(myEvent.message, charCodeMask);
  101.             
  102.             workTEHandle = windTbl[windSub].windTEH[0];        /* get handle            */
  103.             if ((((**workTEHandle).teLength                    /* if there's no room    */
  104.                     + (**workTEHandle).selStart
  105.                     - (**workTEHandle).selEnd) >= 32767)
  106.                 && (workChar != '\b'))                        /* and not a backspace    */ 
  107.                 {
  108.                 PlaceAlert (133);    
  109.                 StopAlert (133, NIL);                            /* stop it            */
  110.                 }
  111.             else
  112.                 {                                                /* otherwise        */
  113.                 TEKey (workChar, windTbl[windSub].windTEH[0]);        /* accept char    */
  114.                 windTbl[windSub].windTEChanged = TRUE;                /* mark changed    */
  115.                 myActionProc (windTbl[windSub].windCntlH[0], 0);    /* rescroll        */
  116.                 WorkRetCode = MenuUpdate(ProcText);                    /* update menus    */
  117.                 }
  118.         break;
  119.         
  120.         case (activateEvt):
  121.             DrawGrowIcon (windTbl[windSub].windPtr);    /* draw grow icon and lines    */
  122.             j = (int) BitAnd(myEvent.modifiers, activeFlag);
  123.  
  124.             if (j)                                /* if activate...                    */
  125.                 {
  126.                 WorkRetCode = MenuUpdate(ProcText);                    /* set menus    */
  127.                 TEActivate (windTbl[windSub].windTEH[0]);            /* hilite        */
  128.                 HiliteControl (windTbl[windSub].windCntlH[0], 0);
  129.                 }
  130.             else                                /* if deactivate...                    */
  131.                 {
  132.                 TEDeactivate (windTbl[windSub].windTEH[0]);
  133.                 HiliteControl (windTbl[windSub].windCntlH[0], 255);    /* unhilite        */
  134.                 }
  135.         break;
  136.         }
  137.  
  138.     return TextWindRetCode;
  139. }
  140.